package com.yuyang.wifi.fragment;

import android.os.Bundle;
import android.text.TextUtils;
import android.util.Log;
import android.view.KeyEvent;
import android.widget.RelativeLayout;

import com.baidu.mobads.sdk.api.CPUWebAdRequestParam;
import com.baidu.mobads.sdk.api.CpuAdView;
import com.baidu.mobads.sdk.api.CpuLpFontSize;
import com.flyco.tablayout.SlidingTabLayout;
import com.yuyang.wifi.R;
import com.yuyang.wifi.adapter.FragmentAdapter;
import com.yuyang.wifi.base.BaseFragment;
import com.yuyang.wifi.constant.AppConstant;
import com.yuyang.wifi.constant.ConstantsMsg;
import com.yuyang.wifi.utils.SpUtil;
import com.yuyang.wifi.utils.eventbus.BaseEvent;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.UUID;

import androidx.viewpager.widget.ViewPager;
import butterknife.BindView;


/**
 * 今日热点
 */

public class TodayHotTabFragment extends BaseFragment {

    private List<String> titles = new ArrayList<>(Arrays.asList("热点", "热榜", "娱乐", "体育", "手机", "财经", "汽车", "房产", "本地", "图片"));
    private List<BaseFragment> mFragments = new ArrayList<>();
    @BindView(R.id.tb_mine)
    SlidingTabLayout tb_mine;
    @BindView(R.id.vpMine)
    ViewPager vpMine;

    public static TodayHotTabFragment newInstance() {
        TodayHotTabFragment fragment = new TodayHotTabFragment();
        return fragment;
    }

    @Override
    protected void initActionBar() {

    }

    @Override
    protected int getLayoutResId() {
        return R.layout.fragment_tab_today_hot_page;
    }

    @Override
    protected void initBizView() {
        for (int i = 0; i < titles.size(); i++) {
            mFragments.add(BaiduAdTabFragment.newInstance(titles.get(i)));
        }
        FragmentAdapter adatper = new FragmentAdapter(getChildFragmentManager(), mFragments, titles);
        vpMine.setAdapter(adatper);
        vpMine.setOffscreenPageLimit(mFragments.size());
        //将TabLayout和ViewPager关联起来。
        tb_mine.setViewPager(vpMine);
        tb_mine.setCurrentTab(0);
        //tb_mine.setCurrentTab(1);
    }

//    @Override
//    public void onMessageEventMain(BaseEvent baseEvent) {
//        super.onMessageEventMain(baseEvent);
//        String tagString = baseEvent.getTagString();
//        Bundle bundle = (Bundle) baseEvent.getData();
//        switch (tagString) {
//            case "mine_refresh":
//
//                break;
//        }
//    }
}
